package org.balthie.cal.impl.cmd;

import org.balthie.cal.core.AbsCommand;
import org.balthie.cal.core.ILiterallyNumb;
import org.balthie.cal.impl.cmd.spec.CmdSizeSpecs;
import org.balthie.cal.impl.cmd.spec.CmdsLiterallyRegexSpecs.CmdsLiterallyRegexSpec;

public class NumbZeroCmd extends AbsCommand implements ILiterallyNumb {

	private static final String LEGAL_PATTERN = "^([1-9]\\d*)|([1-9]\\d*[\\+\\-\\✖\\➗]{1}[1-9]\\d*)$";
	private static final String LEGAL_PATTERN2 = "^([1-9]\\d*[\\+\\-\\✖\\➗]{1})$";
	private static final String LEGAL_PATTERN3 = "^\\d*[\\+\\-\\✖\\➗]{1}$";

	public NumbZeroCmd(String literallyNumb) {
		super(literallyNumb);
		// 数字0前必须有非0数字.运算符
		this.legalSpecs = 
				//	case: 右式非0数字后 +0			
				new CmdsLiterallyRegexSpec(LEGAL_PATTERN, "数字0前必须有非0数字.运算符",this)
				//	case: 数学计算符后 +0				
				.or(new CmdsLiterallyRegexSpec(LEGAL_PATTERN2, "数字0前必须有非0数字.运算符",this))
				// case: 左式只有一个 0				
				.or(CmdSizeSpecs.EMPTY)
				// case: 右式只有一个 0		
				.or(new CmdsLiterallyRegexSpec(LEGAL_PATTERN3, "数字0前必须有非0数字.运算符"));
	}

	@Override
	public String getTips() {
		return "0";
	}
}
